Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support struct for Java #259

Merged
merged 1 commit into from
Oct 17, 2023
Merged

Support struct for Java #259

merged 1 commit into from
Oct 17, 2023

Conversation

honnix
Copy link
Member

@honnix honnix commented Oct 8, 2023

Read then delete this section

TL;DR

Support nested auto-value as input parameters.

Type

  • Bug Fix
  • Feature
  • Plugin

Are all requirements met?

  • Code completed
  • Smoke tested
  • Unit tests added
  • Code documentation added
  • Any pending items have an associated Issue

Complete description

This is to add support for things like:

@AutoValue
class Foo {
  public abstract SdkBindingData<String> foo();

  public abstract SdkBindingData<Bar> bar();
}

@AutoValue
class Bar {
  // note that this is not an SdkBindingData because it doesn't make sense since the whole class is wrapped as a promise
  // this also matches the direction of the existing but disabled IT
  public abstract String bar();
}

Scala layer is not supported yet because it is completely different mechanism.

Tracking Issue

_NA

Follow-up issue

NA


public class LiteralStructDeserializer extends StdDeserializer<Literal> {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was confusing to use Literal as the target but expect a Struct.

interface WriteGenericFunction {
void write(JsonGenerator gen, Struct.Value value) throws IOException;
gen.writeFieldName(VALUE);
new StructSerializer().serialize(value.scalar().generic(), gen, serializerProvider);
Copy link
Member Author

@honnix honnix Oct 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is to serialize a tree that can be directly deserialized into an auto-value object, which is exactly what StructSerializer does.

@honnix honnix changed the title Support struct Support struct for Java Oct 9, 2023
@honnix honnix marked this pull request as ready for review October 9, 2023 09:23
import org.flyte.api.v1.LiteralType;
import org.flyte.flytekit.jackson.JacksonLiteralMap;

public class LiteralMapDeserializers extends Deserializers.Base {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is no longer be used since we don't do a dynamic lookup anymore.


@Override
public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) {
return new SdkBindingDataDeserializer(property.getType().containedType(0));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a funny way to get bean property context.

@honnix honnix force-pushed the blob branch 2 times, most recently from 8fb94fb to ff12243 Compare October 9, 2023 18:17
@honnix honnix force-pushed the struct branch 2 times, most recently from e40e5c2 to e903e57 Compare October 9, 2023 18:45
@honnix
Copy link
Member Author

honnix commented Oct 9, 2023

I can no longer run IT locally because testcontainers generates a warning Unable to mount a file from test host into a running container. This may be a misconfiguration or limitation of your Docker environment. Some features might not work. so I cannot mount things properly during IT.

@honnix
Copy link
Member Author

honnix commented Oct 9, 2023

I can no longer run IT locally because testcontainers generates a warning Unable to mount a file from test host into a running container. This may be a misconfiguration or limitation of your Docker environment. Some features might not work. so I cannot mount things properly during IT.

Trying a fix in #261.

@honnix honnix force-pushed the blob branch 2 times, most recently from 6ea206b to 8284ee3 Compare October 9, 2023 21:09
@honnix honnix force-pushed the struct branch 2 times, most recently from 724849c to 7032727 Compare October 9, 2023 21:15
@@ -1,3 +1,3 @@
version=2.5.2
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not support scala212source3.

@honnix honnix force-pushed the struct branch 3 times, most recently from 6742be4 to 8a84063 Compare October 10, 2023 11:10
@honnix honnix mentioned this pull request Oct 11, 2023
8 tasks
@honnix honnix force-pushed the struct branch 3 times, most recently from b207975 to 768b8bc Compare October 14, 2023 19:57
}

@AutoValue
public abstract static class StructInput {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only discovered these classes in a very late stage so I did not bother adapting test cases to use these.

Signed-off-by: Hongxin Liang <[email protected]>
Copy link
Collaborator

@andresgomezfrr andresgomezfrr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

@andresgomezfrr andresgomezfrr merged commit 78aea79 into blob Oct 17, 2023
3 checks passed
@andresgomezfrr andresgomezfrr deleted the struct branch October 17, 2023 08:09
@honnix
Copy link
Member Author

honnix commented Oct 17, 2023

This branch targets blob branch. Now #258 is a bit hard to review.

honnix added a commit that referenced this pull request Oct 17, 2023
Signed-off-by: Hongxin Liang <[email protected]>
@honnix honnix mentioned this pull request Oct 17, 2023
8 tasks
@andresgomezfrr
Copy link
Collaborator

This branch targets blob branch. Now #258 is a bit hard to review.

oh! I didn't notice that, don't worry, I will continue with the blob's PR

honnix added a commit that referenced this pull request Oct 17, 2023
Signed-off-by: Hongxin Liang <[email protected]>
andresgomezfrr pushed a commit that referenced this pull request Oct 17, 2023
* Bring back Blob support

Signed-off-by: Hongxin Liang <[email protected]>

* Remove BlobTypeDescription

Signed-off-by: Hongxin Liang <[email protected]>

* Add blob back

Signed-off-by: Hongxin Liang <[email protected]>

* Blob in list and map

Signed-off-by: Hongxin Liang <[email protected]>

* Clean up

Signed-off-by: Hongxin Liang <[email protected]>

* Support struct (#259)

Signed-off-by: Hongxin Liang <[email protected]>

* Support struct in Scala layer (#262)

Signed-off-by: Hongxin Liang <[email protected]>

---------

Signed-off-by: Hongxin Liang <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants